//
//  Host_IndexViewController.m
//  penzer
//
//  Created by caiyc on 2018/10/2.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "Host_IndexViewController.h"
#import "ControllViewController.h"
#import "ProfieViewController.h"
#import "PersonViewController.h"
#import "DefaultFixedVC.h"
#import "HostLoginViewController.h"
@interface Host_IndexViewController ()
@property (weak, nonatomic) IBOutlet UIView *botom_View;
- (IBAction)tabbarSelect:(UIButton *)sender;

@end

@implementation Host_IndexViewController
-(void)viewWillAppear:(BOOL)animated{
    if(![XTool GetDefaultInfo:HOST_USER]){
        [WToast showWithText:@"请登录"];
        HostLoginViewController *vc = [[HostLoginViewController alloc]init];
        [self pushSecondVC:vc];
        return;
    }else{
        
    }
}
- (void)viewDidLoad {
    [super viewDidLoad];
    if([XTool GetDefaultInfo:HOST_USER]){
    [self setcontentViews];
    }
    
    // Do any additional setup after loading the view from its nib.
}
-(void)setcontentViews{
    //self.bottom_ScrioView.backgroundColor = [UIColor redColor];
    self.bottom_ScrioView.contentSize = CGSizeMake(screen_width*3, self.bottom_ScrioView.frame.size.height);
    self.bottom_ScrioView.scrollEnabled = 0;
   ControllViewController *vc = [[ControllViewController alloc]init];
    vc.view.frame = CGRectMake(0, 0, screen_width, self.bottom_ScrioView.frame.size.height);
    [self.bottom_ScrioView addSubview:vc.view];
    [self addChildViewController:vc];
    ProfieViewController *vc1 = [[ProfieViewController alloc]init];
    vc1.view.frame = CGRectMake(screen_width*1, 0, screen_width, self.bottom_ScrioView.frame.size.height);
    [self.bottom_ScrioView addSubview:vc1.view];
    [self addChildViewController:vc1];
    PersonViewController *vc2 = [[PersonViewController alloc]init];
    vc2.view.frame = CGRectMake(screen_width*2, 0, self.bottom_ScrioView.frame.size.width, self.bottom_ScrioView.frame.size.height);
    [self.bottom_ScrioView addSubview:vc2.view];
    [self addChildViewController:vc2];
    self.title1.textColor = BUTTON_COLOR;
    UIButton *btn1 = (UIButton *)[self.view viewWithTag:1024];
    btn1.selected = 1;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)tabbarSelect:(UIButton *)sender {
//   sender.selected=!sender.selected;
    UIButton *btn1 = (UIButton *)[self.view viewWithTag:1024];
    UIButton *btn2 = (UIButton *)[self.view viewWithTag:1025];
    UIButton *btn3 = (UIButton *)[self.view viewWithTag:1026];
    if(sender.tag==0){
        self.title1.textColor = BUTTON_COLOR;
        self.title2.textColor = [UIColor darkGrayColor];
        self.title3.textColor = [UIColor darkGrayColor];
        btn1.selected = 1;
        btn2.selected = 0;
        btn3.selected = 0;
    }else if (sender.tag==1){
        self.title2.textColor = BUTTON_COLOR;
        self.title1.textColor = [UIColor darkGrayColor];
        self.title3.textColor = [UIColor darkGrayColor];
        btn1.selected = 0;
        btn2.selected = 1;
        btn3.selected = 0;
    }else{
        self.title3.textColor = BUTTON_COLOR;
        self.title2.textColor = [UIColor darkGrayColor];
        self.title1.textColor = [UIColor darkGrayColor];
        btn1.selected = 0;
        btn2.selected = 0;
        btn3.selected = 1;
    }
    NSInteger off = sender.tag;
    [self.bottom_ScrioView setContentOffset:CGPointMake(screen_width*off, 0) animated:1];
}
@end
